package com.explorati.design_pattern.behavior.iterator;

import java.util.List;

public class Test {
	public static void main(String[] args) {
		Course course1 = new Course("设计模式");
		Course course2 = new Course("Java设计模式");
		Course course3 = new Course("Python课程");
		Course course4 = new Course("Java课程");

		CourseAggregate courseAggregate = new CourseAggregateImpl();
		courseAggregate.addCourse(course1);
		courseAggregate.addCourse(course2);
		courseAggregate.addCourse(course3);
		courseAggregate.addCourse(course4);

		System.out.println("课程列表----------");
		printCourse(courseAggregate);
		courseAggregate.removeCourse(course4);

		System.out.println("课程列表----------");
		printCourse(courseAggregate);
	}

	private static void printCourse(CourseAggregate courseAggregate) {
		CourseIterator courseIterator = courseAggregate.getCourseIterator();
		while (!courseIterator.isLastCourse()) {
			Course course = courseIterator.nextCourse();
			System.out.println(course.getName());

		}
	}

}
